package com.spring.le.config;

import lombok.Getter;
import lombok.Setter;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class LogInterceptor implements InvocationHandler {
    //被代理的对象
    @Setter
    @Getter
    private Object target;

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //代理到这个方法
        System.out.println("执行前");
        //
        Object res = method.invoke(target, args);
        //返回这个方法的返回
        System.out.println("执行后");
        return res;
    }
}
